<layout:sign/>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#" style="color:#fff"><b>Admin</b>LTE</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">登录以开启新的会话</p>

        <form name="login">
            <div class="form-group has-feedback">
                <input type="text" name="username" class="form-control valinput" placeholder="邮件/手机/账号">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="password" class="form-control valinput" placeholder="密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox" id="remember" checked> 记住我
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="button" id="submit" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
                <!-- /.col -->
            </div>
            <input type="password" style="position:absolute;top: -999px;"/>
        </form>

        <!--        <div class="social-auth-links text-center">-->
        <!--            <p>- 或者 -</p>-->
        <!--            <a href="__PUBLIC__/admin/sns/index" class="btn btn-block btn-social btn-facebook btn-flat"><i-->
        <!--                        class="fa fa-openid"></i> 使用钉钉登录 </a>-->
        <!--        </div>-->
<!--        <div id="login_container"></div>-->
        <a href="__PUBLIC__/admin/sign/forgot">忘记密码</a>
        <br>
        <br>
        <a data-href="__PUBLIC__/signup" class="text-center">注册新账号（暂不可用）</a>

    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

</body>
<script>

    $(function () {

        document.login.username.value = '';
        document.login.password.value = '';

        if ((BROWSER.type === "ie") && (BROWSER.version < 10)) {
            alert('你的浏览器版本过低');
        } else {
            var refer = "<?php echo $_GET['refer']??'';?>";
            isea.ready(function () {
                isea.loader.use('encrypt', function () {
                    var submit = function () {
                        if (!document.login.username.value || !document.login.password.value) {
                            return alert('username or password should not be empty!')
                        }
                        $.get("__PUBLIC__/admin/sign/in", {
                            refer: refer,
                            token: "{{token}}",
                            username: document.login.username.value,
                            password: isea.encrypt.md5(isea.encrypt.sha1(document.login.password.value)),
                            remember: $("#remember").is(":checked") ? 1 : 0
                        }, function (data) {
                            if (data.message) alert(data.message);
                            if (data.redirect) location.href = data.redirect;
                        })
                    };

                    document.getElementById("submit").onclick = submit;
                    $(".valinput").keyup(function (e) {
                        if (e.keyCode === 13) {
                            submit();
                        }
                    });
                });
            });
        }
    });


</script>
